package com.example.clothingmanager.controller;

import com.example.clothingmanager.bean.Instock;
import com.example.clothingmanager.service.InstockService;
import com.example.clothingmanager.utils.InstockQuery;
import com.example.clothingmanager.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Huangyt
 * @version 1.0
 * @date 2020/5/9 15:53
 */
@RestController
@RequestMapping("/instock")
public class InstockController {
    @Autowired
    InstockService instockService;

    @GetMapping("/list/{page}/{size}")
    public Result list(@PathVariable("page")int page, @PathVariable("size")int size, int depotid, InstockQuery query){
        return instockService.list(depotid, page, size, query);
    }

    @PostMapping("/add")
    public Result add(@RequestBody Instock instock){
        return instockService.add(instock);
    }

    @PutMapping("/update")
    public Result update(@RequestBody Instock instock){
        return instockService.update(instock);
    }

    @DeleteMapping("/del/{isitem}")
    public Result delete(@PathVariable("isitem")String isitem){
        return instockService.delete(isitem);
    }

    @GetMapping("/get/{isitem}")
    public Result get(@PathVariable("isitem")String isitem){
        return instockService.get(isitem);
    }

    @GetMapping("/get/name")
    public Result getNames(){
        return instockService.getNames();
    }
}
